﻿USE [IvyDB]
GO

/****** Object:  Table [dbo].[UserRole]    Script Date: 09/11/2014 14:23:24 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UserRole]') AND type in (N'U'))
DROP TABLE [dbo].[UserRole]
GO

USE [IvyDB]
GO

/****** Object:  Table [dbo].[UserRole]    Script Date: 09/11/2014 14:23:24 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[UserRole](
	[UserKey] [int] NOT NULL,
	[UserRoleKey] [int] NOT NULL,
	[UserLoginID] [varchar](50) NOT NULL,
	[UserRoleCode] [nchar](20) NOT NULL,
	[Sys_DateOfCreation] [datetime] NOT NULL,
	[Sys_DateOfModification] [datetime] NOT NULL,
	[Sys_CreatedByID] [varchar](50) NOT NULL,
	[Sys_ModifiedByID] [varchar](50) NOT NULL,
	[Sys_DeleteType] [int] NOT NULL,
	[Sys_IsDeleted] [bit] NOT NULL,
	[Sys_OrganizationID] [int] NOT NULL,
	[Sys_InitialPrimaryKeys] [varchar](max) NULL,
	[Sys_WorkstationName] [varchar](50) NULL,
 CONSTRAINT [PK_UserRole] PRIMARY KEY CLUSTERED 
(
	[UserKey] ASC,
	[UserRoleKey] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'0=Can be Deleted physically, 1=Only Soft Delete.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_DeleteType'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Used where ever soft delete is allowed. Default value is not deleted - false or zero.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_IsDeleted'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for SaaS type deployment, by default it should have avalue of -1 to represent non SaaS deployment.' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_OrganizationID'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. XML node to hold Initial Primary Keys (Key value pair in case of multi field primary key).' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_InitialPrimaryKeys'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'This is helpful for smart client offline transaction data with distributed database, this is helpful after data synchronization. ' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'UserRole', @level2type=N'COLUMN',@level2name=N'Sys_WorkstationName'
GO


